<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::middleware('auth:api')->get('/user', function (Request $request) {
    //return $request->user();
});
//Route::group(['namespace' => 'Basic'], function () {
//    Route::post('upload', 'UploadController@put');
//    Route::any('weixin', 'WeixinController@index');
//    Route::any('weixin-test/pay', 'WeixinController@pay');
//    Route::any('weixin/pay', 'WeixinController@pay');
//    Route::any('profile', 'WeixinController@profile');
//
//});



Route::group(['namespace' => 'Basic', 'prefix'=>''], function()
{
    Route::Post('/imgupload', 'UploadController@putImg');
    //Route::any('/ueditor', 'UploadController@ueditor');
    //Route::get('/captcha/app', 'CatpchaController@app');
    Route::get('/captcha', 'CatpchaController@index');
    Route::post('/verifycode', 'SmsController@create');
    Route::post('/phone/verifycode', 'SmsController@nocaptcha');
    Route::get('/city', 'MiscController@city');
    Route::get('/area/{type}', 'MiscController@cityByName');

    Route::get('/download/{date}', 'MiscController@downloadUserData');
});

//v1通用接口
Route::group(['namespace' => 'v1', 'prefix'=>'v1',], function()
{
    Route::any('/wechat/callback', 'WeixinController@payCallback');
    Route::get('/goods/buy', 'DuiBaController@buy');
    Route::get('/goods/notify', 'DuiBaController@notify');


    Route::get('/platform/index', 'PlatformController@index');
    Route::get('/platform/project', 'PlatformController@project');
    Route::get('/platform/org', 'PlatformController@org');
    Route::get('/platform/volunteer', 'PlatformController@volunteerInfo');

    Route::get('/platform/team', 'PlatformController@team');
    Route::get('/platform/claim', 'PlatformController@claim');

    Route::get('/platform/news', 'PlatformController@news');
    Route::get('/news/{id}', 'NewsController@info')->where('id', '[0-9]+');


});

Route::group(['namespace' => 'v1', 'prefix'=>'v1', 'middleware'=>['verifyOrgCode']], function()
{
    Route::Post('/register', 'UserController@register');
    Route::Post('/login', 'UserController@login');
    Route::Post('/login/phone', 'UserController@loginByPhone');
});


//不需要token的
Route::group(['namespace' => 'v1', 'prefix'=>'v1', 'middleware'=>[ 'verifyOrgCode'],], function()
{

    Route::post('/reset/pwd', 'UserController@resetPwd');

    Route::get('/team', 'TeamController@listInfo');
    Route::get('/team/{id}', 'TeamController@info')->where('id', '[0-9]+');

    Route::get('/index', 'IndexController@info');
    Route::get('/project/{id}', 'ProjectController@info')->where('id', '[0-9]+');
    Route::get('/project', 'ProjectController@listInfo');
    Route::get('/project/user/{id}', 'ProjectController@user')->where('id', '[0-9]+');
    Route::get('/weixin/media', 'IndexController@weixinMedia');
    Route::get('/goodexample', 'GoodExampleController@index');
    Route::get('/goodexample/{id}', 'GoodExampleController@show');

    Route::get('/insurance', 'InsuranceController@index');
    Route::get('/insurance/{id}', 'InsuranceController@show');

    Route::get('/claim', 'ClaimController@listInfo');
    Route::get('/claim/{id}', 'ClaimController@info')->where('id', '[0-9]+');

    Route::get('feeling', 'FeelingController@index');
    Route::get('feeling/{id}', 'FeelingController@info')->where('id', '[0-9]+');


    Route::get('/banner', 'ScoreController@bannerlist');
    Route::get('goods/list','ScoreController@goodslist');
    Route::get('goods/{id}','ScoreController@goods')->where('id', '[0-9]+');


    Route::get('/news/list', 'NewsController@index');


});

//需要token的
Route::group(['namespace' => 'v1', 'prefix'=>'v1', 'middleware'=>['verifyToken', 'verifyOrgCode'],], function()
{

    Route::get('/user', 'UserController@info');
    Route::get('/logout', 'UserController@logout');
    Route::post('/user', 'UserController@edit');
    Route::post('/user/check', 'UserController@realname');
    Route::post('/user/collection', 'UserController@collection');
    Route::post('/user/uncollection', 'UserController@deleteCollection');
    Route::get('/user/collection', 'UserController@collectList');
    Route::post('/myfamily', 'FamilyController@create');
    Route::post('/myfamily/bind', 'FamilyController@bind');
    Route::get('/myfamily', 'FamilyController@listInfo');
    Route::get('/myfamily/{id}', 'FamilyController@info')->where('id', '[0-9]+');
    Route::delete('/myfamily/{id}', 'FamilyController@delete')->where('id', '[0-9]+');
    Route::put('/myfamily/{id}', 'FamilyController@edit')->where('id', '[0-9]+');
    Route::get('/message', 'MessageController@listInfo');

    Route::post('/team/join/{id}', 'TeamController@join')->where('id', '[0-9]+');
    Route::post('/project/join/{id}', 'ProjectController@join')->where('id', '[0-9]+');

    Route::get('/user/team', 'UserTeamController@index');
    Route::get('/user/project', 'UserProjectController@index');
    Route::get('/user/reward/time', 'UserProjectController@reward');

    Route::get('/project/apply', 'UserProjectController@applyProject');

    Route::post('/user/apply', 'UserApplyController@create');
    Route::get('/user/apply', 'UserApplyController@index');

    Route::post('/clock/in', 'UserClockController@create');
    Route::get('/clock/in', 'UserClockController@index');
    Route::get('/user/center', 'IndexController@userCenter');


    Route::get('/user/score/{type}', 'UserController@scoreList');

    Route::post('/claim/{id}', 'ClaimController@join')->where('id', '[0-9]+');

    Route::post('/user/phone', 'UserController@resetPhone');

    Route::post('feeling', 'FeelingController@store');
    Route::delete('feeling/{id}', 'FeelingController@delete')->where('id', '[0-9]+');
    Route::get('feeling/my', 'FeelingController@my');

    Route::get('feeling/like/{id}', 'FeelingController@like')->where('id', '[0-9]+');
    Route::get('feeling/dislike/{id}', 'FeelingController@dislike')->where('id', '[0-9]+');

    Route::post('/feeling/comment/{id}', 'FeelingController@comment')->where('id', '[0-9]+');
    Route::delete('comment/{id}', 'FeelingController@delcomment')->where('id', '[0-9]+');
    Route::get('comment/new', 'FeelingController@newcomment');

    Route::get('goods/change/{id}','ScoreController@change')->where('id', '[0-9]+');
    Route::get('order/myorders','ScoreController@orders');
    Route::get('order/collect/{id}','ScoreController@collect')->where('id', '[0-9]+');

});
